<template>
  <div>
    <div style="color: #666; display: inline-block; ">题干:<em style="color: red">*</em></div>
    <KindEditor :content.sync="exerciseEntry.question"
                :uploadPath="'exercise/' + exerciseEntry.id"/>
    <EditChoiceArray v-if="exerciseEntry.role !== CONST.EXERCISE_GROUP_ROLE_B" :exerciseEntry='exerciseEntry' :choiceArray="exerciseEntry.choiceArray"/>
    <div style="color: #666; display: inline-block; " >答案:<em style="color: red">*</em></div>
    <div v-for="(item, idx) in exerciseEntry.choiceArray"
         style="display: inline-block; margin-left: 20px; " >
      <el-checkbox v-if="exerciseEntry.role === CONST.EXERCISE_GROUP_ROLE_CASE" v-model="answerArray"
                   :label="String.fromCharCode(65 + idx)"></el-checkbox>
      <el-radio v-else v-model="exerciseEntry.answer"
                :label="String.fromCharCode(65 + idx)"/>
    </div>
    <div style="color: #666; ">解析:</div>
    <KindEditor :content.sync="exerciseEntry.answerAnalyses"
                :uploadPath="'exercise/' + exerciseEntry.id"/>
  </div>
</template>

<script>
  import EditChoiceArray from "./EditChoiceArray";
  export default {
    name: "EditExerciseEntry",
    components: {EditChoiceArray},
    props: ['exerciseEntry'],
    data() {
      return {
        answerArray: [],
      }
    },
    watch: {
      answerArray() {
        this.exerciseEntry.answer = JSON.parse(JSON.stringify(this.answerArray)).sort().join('')
      }
    },
    methods: {
    },
    created() {
      if (this.exerciseEntry.answer) {
        this.answerArray = this.exerciseEntry.answer.split('')
      }
    }
  }
</script>

<style scoped>
</style>
